package com.genesis.web.controller.pmsbrandAndproduct;


import com.genesis.mall.common.Result;
import com.genesis.mall.dto.PageDto;
import com.genesis.mall.entity.PmsBrand;
import com.genesis.mall.entity.PmsProduct;
import com.genesis.mall.service.IPmsBrandService;
import com.genesis.mall.service.IPmsProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 品牌表 前端控制器
 * </p>
 *
 * @author Hshuai
 * @since 2022-08-01
 */
//@RestController
//@RequestMapping("/brand")
public class PmsBrandController {

    @Autowired
    private IPmsBrandService pmsBrandService;
    @Autowired
    private IPmsProductService productService;

    /**
     * 获取品牌详情
     * @param brandId
     * @return
     */
    @GetMapping("/detail/{brandId}")
    public Result getDetail(@PathVariable Long brandId){
        return Result.success(pmsBrandService.getById(brandId));
    }

    /**
     * 分页获取品牌商品
     * @param brandId
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/productList")
    public Result<PageDto<PmsProduct>> productList(Long brandId, Integer pageNum, Integer pageSize){
            return Result.success(productService.pageList(brandId,pageNum,pageSize));
    }

    /**
     * 分页获取推荐品牌
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/recommendList")
    public Result<List<PmsBrand>> recommendList(Integer pageNum, Integer pageSize){

        return Result.success(pmsBrandService.pageList(pageNum,pageSize));

    }

}
